# Recipe file for mpv.
#
# Maintainers: (C) 2017 Mateus P. Rodrigues, mprodrigues@dragora.org.
#
# Under the terms of the GNU General Public License.

program=mpv
version=0.26.0
release=1

description="
Video player based on MPlayer/mplayer2.
"

homepage=https://mpv.io
license=GPLv2

tarname=${program}-${version}.tar.gz

# Remote source(s)
fetch="https://github.com/mpv-player/mpv/archive/v0.26.0.tar.gz"

# Parallel jobs for the compiler
jobs=1

# Source documentation
docs="Copyright LICENSE README.md RELEASE_NOTES"

build() {
    unpack "${tardir}/$tarname"

    cd "$srcdir"

    python2.7 bootstrap.py

    ./waf configure \
    --prefix=/usr \
    --mandir=/usr/man \
    --libdir=/usr/lib${SUFARCH} \
    --disable-wayland

    ./waf install \
    --destdir=$PKG \

    # Compress manual pages
    if [ -d "${destdir}/$mandir" ] ; then
	(
            cd "${destdir}/$mandir"
	    find . -type f -exec lzip -9 '{}' +
	    find . -type l | while read -r file
	    do
		ln -sf "$(readlink -- "$file").lz" "${file}.lz"
		rm -- "$file"
	    done
	)
    fi

    # Copy documentation
    mkdir -p "${destdir}/usr/local/share/doc/${program}-${version}"
    cp -p $docs "${destdir}/usr/local/share/doc/${program}-${version}/"
}
